let app = getApp()
Page({
  /**
   * 页面的初始数据
   */
  data: {
    color:false
  },
  onLoad: function (options) {
    new app.ToastPannel();
  },

  formSubmit: function (e) {
    var that = this
    var key = wx.getStorageSync('key')
    var uid = wx.getStorageSync('u')
    var user_directseller_shop = e.detail.value.user_directseller_shop
    if (user_directseller_shop.length == 0) {
      wx.showToast({
        title: '不能为空',
        icon: 'loading',
        duration: 2000
      }) 
    }else {
      wx.request({
        url: app.configData.shop.api_url + '/index.php?ctl=Distribution_Buyer_Directseller&met=setShopName&typ=json',
        data: { k: key, u: uid, user_directseller_shop: user_directseller_shop,},
        method: 'POST', 
        header: {
          "Content-Type": "application/x-www-form-urlencoded"
        }, // 设置请求的 header
        success: function (res) {

          if (res.data.status == 200) {
            wx.showToast({
              title: '设置成功',
              icon: 'success',
              duration: 2000
            }) 
              wx.redirectTo({
                url: '../directseller/directseller',
              })

          } else {
            wx.showToast({
              title: '设置失败',
              icon: 'loading',
              duration: 2000
            }) 
          
          }
        },
        fail: function (res) {
          wx.showToast({
            title: '设置失败',
            icon: 'loading',
            duration: 2000
          }) 
        }
      })
    }

  },
  user_directseller_shop:function(e){
   var that = this
   var content = e.detail.value
   if (content){
     that.setData({
       color: true
     })
   }else{
     that.setData({
       color: false
     })
   }
  
  }
})